package cn.wzptsoft.tinymallbe.entity;


import cn.wzptsoft.common.utils.JsonUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.util.JSONPObject;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Entity
@Getter
@Setter
@Table(name = "`order`")
public class Order extends BaseEntity{

    private String orderNo;

//   商品详情
    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "orderId")
    private List<OrderItem> items;


    public Object getSnapAddress() throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        Address address = objectMapper.readValue(snapAddress, Address.class);
        return address;
    }
    //    收货地址
    private String snapAddress;

//    订单状态 0 待支付  1 待发货  2 待收货  4 取消
    private Integer status;

//    总价格
    private Double totalAmount;
//    总个数
    private Integer totalCount;
//    用户id
    private Integer userId;

}
